<!doctype html>
<html  class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>后台登录</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/login.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .login hr.hr15{
            height:5px;
        }
        .layui-input{
            height:40px;
        }
    </style>
</head>
<body class="login-bg">

<div class="login layui-anim layui-anim-up" style="margin-top: 5px;padding-bottom: 5px;padding-top: 15px;">
    <div class="message">天津市学生心理健康教育发展中心</div>
    <div id="darkbannerwrap"></div>

    <form method="post" class="layui-form" >
        <input name="name" placeholder="请输入用户名 与姓名无关"  type="text" lay-verify="required" class="layui-input" style="margin-top: -20px;">
        <hr class="hr15">
        <input name="pass" lay-verify="required" placeholder="请输入密码"  type="password" class="layui-input">
        <hr class="hr15">
        <input name="repass" lay-verify="required" placeholder="确认密码"  type="password" class="layui-input">
        <hr class="hr15">
        <select name="sex">
            <option value="">选择性别</option>
            <option value="男">男</option>
            <option value="女">女</option>
        </select>
        <hr class="hr15">
        <input name="birthday" placeholder="出生日期" id="date" autocomplete="off" style="height:40px;" class="layui-input"/>
        <hr class="hr15">
        <input name="idcard" placeholder="身份证号" autocomplete="off" style="height:40px;" class="layui-input"/>
        <hr class="hr15">
        <input name="email" placeholder="邮箱地址" autocomplete="off" style="height:40px;" class="layui-input"/>
        <hr class="hr15">
        <select lay-filter="city">
            <option value="">--请选择城市--</option>
            {volist name="area" id="vo"}
                <option value="{$vo.id}">{$vo.title}</option>
            {/volist}
        </select>
        <select id="qu" lay-filter="qu" name="area">
            <option value="">--请选择教委--</option>
        </select>
        <select id="school" name="school">
            <option value="">--请选择学校--</option>
        </select>
        <hr class="hr15">
        <select name="if_teacher">
            <option value="">是否为专职教师</option>
            <option value="1">是</option>
            <option value="2">否</option>
        </select>
        <hr class="hr15">
        <input name="professiona" placeholder="职称" autocomplete="off" style="height:50px;" class="layui-input"/>
        <hr class="hr15">
        <select name="job">
            <option value="">职位</option>
            <option value="1">校长</option>
            <option value="2">德育主任</option>
            <option value="3">班主任</option>
            <option value="4">其他</option>
        </select>
        <hr class="hr15">
        <input name="phone" placeholder="手机号码" id="phone" autocomplete="off" style="height:50px;" class="layui-input"/>
        <hr class="hr15">
        <div class="layui-form-item">
            <label class="layui-form-label" > <button type="button" id="send_but" onclick="send()" class="layui-btn layui-btn-primary">获取验证码</button></label>
            <div class="layui-input-block">
                <input type="text" name="code" id="code" lay-verify="required" lay-reqtext="验证码必填" placeholder="请输入手机验证码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <hr class="hr15">
        <input value="注册" lay-submit lay-filter="login" style="width:100%;height:45px;" type="submit">
        <input value="返回" lay-filter="login" style="width:100%;margin-top: 15px;height:45px;" type="button" onclick="rback()" />
        <hr class="hr20" >
        <input value="{$code}" name="kcode" type="hidden" />
    </form>
</div>

<script>
    $(function  () {
        layui.use(['form','laydate'], function(){
            var form = layui.form;
            var laydate = layui.laydate;
            form.on('select(city)',function(data){
                // console.log(data.value);
                $.ajax({
                    url:'/index/register/getqu',
                    data:{id:data.value},
                    type:'post',
                    dataType:'json',
                    success:function(res){
                        $("#cid").html("");
                        $.each(res.msg, function(key, val) {
                            var option1 = $("<option>").val(val.id).text(val.title);
                            $("#qu").append(option1);
                            form.render('select');
                        });
                        // $("#cid").get(0).selectedIndex=0;
                    }
                });
            });
            form.on('select(qu)',function(data){
                // console.log(data.value);
                $.ajax({
                    url:'/index/register/getschool',
                    data:{id:data.value},
                    type:'post',
                    dataType:'json',
                    success:function(res){
                        $("#cid").html("");
                        $.each(res.msg, function(key, val) {
                            var option1 = $("<option>").val(val.id).text(val.title);
                            $("#school").append(option1);
                            form.render('select');
                        });
                        // $("#cid").get(0).selectedIndex=0;
                    }
                });
            });
            laydate.render({
                elem: '#date'
            });
            //监听提交
            form.on('submit(login)', function(data){
                console.log($("#agreen").is(':checked'));
                // var agreen = $("#agreen").is(":checked");
                // if(!agreen){
                //     layer.msg('请阅读用户协议');
                //     return false;
                // }
                var phone = $("#phone").val();

                var code = $("#code").val();
                if(phone==''){
                    layer.msg('请输入手机号');
                    return false;
                }
                if(code==''){
                    layer.msg('请输入手机验证码');
                    return false;
                }
                $.ajax({
                    url:'',
                    type:'post',
                    data:$('.layui-form').serialize(),
                    dataType:'json',
                    success:function (data) {
                        if (data.status == 1) {
                            layer.msg("注册成功,请稍后", {offset:'50%',icon: 6,time:500},function(){
                                location.href='/';
                            });
                        }
                        if(data.status == 2) {
                            layer.msg("您的用户名或密码有误 或者 您的账户已被禁用", {offset:'50%',icon: 5,time:500}, function () {
                                // 关闭模态框
                                x_admin_close();
                                // 刷新页面
                                parent.location.reload();
                            });
                        }

                        if(data.status == 0) {
                            layer.msg(data.msg, {offset:'50%',icon: 5,time:500}, function () {
                                // 关闭模态框
                                x_admin_close();
                                // 刷新页面
                                parent.location.reload();
                            });
                        }
                    }
                });
                return false;
            });
        });
    })
    function rback(){

        window.location.href="javascript:history.go(-1)";
    }
    var num = 0;
    function send(){
        var phone = $("#phone").val();
        $.ajax({
            url: '/index/register/sendmessage',
            type: 'post',
            data: {phone:phone},
            dataType: 'json',
            success: function (data) {
                if(data.status==1){
                    layer.msg('发送成功');
                    num = 60;
                    daojishi();
                }else{
                    layer.msg(data.msg);
                }
            }
        })
      
    }
    function daojishi() {
        // alert(123);
        $("#send_but").html(+num + 's后发送');
        num--;
        if (num > 0) {
            $("#send_but").attr('disabled', 'disabled');
            setTimeout(function() {
                daojishi()
            },
            1000);
        } else {
            $("#send_but").attr('disabled', false);
            $("#send_but").html('获取验证码');
        }
    
    }
</script>
</body>
</html>